import CcRequest from './request'
import { BASE_URL, TIME_OUT } from './request/config'
// import localStorage from '@/utils/cache'

const ccRequest = new CcRequest({
  baseURL: BASE_URL,
  timeout: TIME_OUT,
  interceptors: {
    requestInterceptor: (config) => {
      // console.log('请求成功的拦截 - 实例级别')
      // 实例级别携带 token

      // const token = localStorage.getCache('token') || ''
      // if (token) {
      //   config.headers!.Authorization = `Bearer ${token}`
      // }
      return config
    },
    requestInterceptorCatch: (err) => {
      // console.log('请求失败的拦截  - 实例级别')
      return err
    },
    responseInterceptor: (config) => {
      // console.log('响应成功的拦截  - 实例级别')
      return config
    },
    responseInterceptorCatch: (err) => {
      // console.log('响应失败的拦截  - 实例级别')
      return err
    }
  }
})
export default ccRequest
